<template>
  <div class="main">
    <div class="listBox" v-for="item in list" :key="item">
      <div class="top" v-if="item.has_one_member">
        <div class="img">
          <img :src="item.has_one_member.avatar_image" alt="" />
        </div>
        <div class="right">
          <div class="right_top">
            <div class="name">{{ item.has_one_member.nickname }}</div>
            <div class="txt">当天第{{ item.second }}次访问</div>
          </div>
          <div class="right_top">
            <div class="id">ID：{{ item.has_one_member.uid }}</div>
            <div class="time">{{ item.created_at }}</div>
          </div>
        </div>
      </div>
      <div class="type">
        <div class="type_left">页面类型：</div>
        {{ item.page_type }}
      </div>
      <div class="type">
        <div class="type_left">页面标题：</div>
        {{ item.title }}
      </div>
      <div class="type">
        <div class="type_left">访问端口：</div>
        {{ item.port_name }}
      </div>
      <div class="type">
        <div class="type_left">页面URL：</div>
        <div class="btn" @click="toUrl(item.url)">访问</div>
        <div class="copyBtn" v-clipboard:copy="item.url" v-clipboard:success="onCopy">复制</div>
      </div>
      <div class="wcPhone" v-if="item.has_one_member">
        <i class="iconfont icon-card_weixin1" v-clipboard:copy="item.has_one_member.wechat" v-clipboard:success="onCopy" v-if="display_set.wechat && item.has_one_member.wechat"></i>
        <i class="iconfont icon-card_phone" @click="telCall(item.has_one_member.mobile)" v-if="display_set.phone && item.has_one_member.mobile"></i>
      </div>
    </div>
    
  </div>
</template>
<script>
import { Toast } from "vant";
export default {
  props: {
    list: {
      type: null
    },
    display_set: {
      type: null
    }
  },
  data() {
    return {};
  },
  methods: {
    telCall(phone) {
      window.location.href = `tel://${phone}`;
    },
    toUrl(url) {
      window.location.href = url;
    },
    onCopy() {
      Toast({
        message: "复制成功",
        position: "bottom",
        duration: 1500
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.listBox {
  margin: 0 0.75rem;
  border-radius: 0.5rem;
  padding: 1rem 1rem 1rem 0.75rem;
  background: #fff;
  position: relative;
  margin-bottom: 0.625rem;

  .wcPhone {
    position: absolute;
    right: 1rem;
    bottom: 1.6875rem;
    display: flex;
    align-items: center;

    .iconfont {
      font-size: 1.6rem;
      color: var(--themeBaseColor);
    }

    .icon-card_weixin1 {
      margin-right: 0.5rem;
    }
  }

  .type {
    text-align: left;
    line-height: 1.1875rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    font-size: 0.8125rem;

    .type_left {
      color: #999;
    }

    .btn {
      background: var(--themeBaseColor);
      color: #fff;
      padding: 0.0625rem 0.5rem;
      border-radius: 12px;
    }

    .copyBtn {
      color: var(--themeBaseColor);
      padding: 0.0625rem 0.5rem;
      border: 1px solid var(--themeBaseColor);
      border-radius: 12px;
      margin-left: 0.5rem;
    }
  }

  .top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8125rem;

    .img {
      flex-shrink: 0;
      border-radius: 50%;
      width: 2.25rem;
      height: 2.25rem;
      margin-right: 0.5rem;

      img {
        border-radius: 50%;
        width: 2.25rem;
        height: 2.25rem;
      }
    }

    .right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .right_top {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .name {
          font-size: 0.8125rem;
          color: #333;
        }

        .txt {
          font-size: 0.75rem;
          color: var(--themeBaseColor);
        }

        .id {
          font-size: 0.75rem;
          color: #999;
        }

        .time {
          font-size: 0.75rem;
          color: #999;
        }
      }
    }
  }
}
</style>